package gpl.pierrick.brihaye.aramorph;

import java.util.logging.Level;
import java.util.logging.Logger;

public class CreateDB {
	private static final Logger logger = Logger.getLogger(CreateDB.class.getName());
	
	public static void main(String[] args) {
		Logger.getLogger("").setLevel(Level.ALL);
		logger.setLevel(Level.ALL);
		//create the database if it does not exist
		logger.info("Creating Database");
		DBManager.createDB();

		logger.info("Creating PREFIXES");
		JDBCDictionary prefixes = new JDBCDictionary("DICT_PREFIXES",false);
		prefixes.createFromXML(CreateDB.class.getResourceAsStream("/dictionaries/dictPrefixes.xml"));
		logger.info("Creating STEMS");
		JDBCDictionary stems = new JDBCDictionary("DICT_STEMS",false);
		stems.createFromXML(CreateDB.class.getResourceAsStream("/dictionaries/dictStems.xml"));
		logger.info("Creating SUFFIXES");
		JDBCDictionary suffixes = new JDBCDictionary("DICT_SUFFIXES",false);
		suffixes.createFromXML(CreateDB.class.getResourceAsStream("/dictionaries/dictSuffixes.xml"));
		
		logger.info("Creating Table AB");
		JDBCCompatibilityTable tableAB = new JDBCCompatibilityTable("TABLE_AB");
		tableAB.createFromXML(CreateDB.class.getResourceAsStream("/dictionaries/tableAB.xml"));
		logger.info("Creating Table BC");
		JDBCCompatibilityTable tableBC = new JDBCCompatibilityTable("TABLE_BC");
		tableBC.createFromXML(CreateDB.class.getResourceAsStream("/dictionaries/tableBC.xml"));
		logger.info("Creating Table AC");
		JDBCCompatibilityTable tableAC = new JDBCCompatibilityTable("TABLE_AC");
		tableAC.createFromXML(CreateDB.class.getResourceAsStream("/dictionaries/tableAC.xml"));
		logger.info("Creating Indices");
		DBManager.createIndices();
	}

}
